<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>编辑种子·思通投研·让数据驱动投资价值!</title>

<link href="${pageContext.request.contextPath }/img/webLogoIcon.png"
	rel="shortcut icon">
<link href="${pageContext.request.contextPath }/css/bootstrap.min.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath }/css/font-awesome.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath }/css/custom.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath }/css/animate.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath }/css/style.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath }/css/datatables.min.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath }/css/toastr.min.css"
	rel="stylesheet" />
<link
	href="${pageContext.request.contextPath }/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath }/css/plugins/sweetalert/sweetalert.css"
	rel="stylesheet">

<link
	href="${pageContext.request.contextPath }/css/jquery.searchableSelect.css"
	rel="stylesheet" type="text/css">
<style>
.select2_demo_1 {
	float: left;
	width: 120px;
	display: inline;
	margin-left: 10px;
}

.form-control {
	display: inline;
}

.col-sm-3 {
	float: right;
	width: 560px;
}

.input-group {
	float: right;
	width: 240px;
	margin-left: 5px;
}

.checkbox {
	padding-left: 35px;
	float: left;
}
</style>
</head>

<body>

	<div id="wrapper">

		<nav class="navbar-default navbar-static-side" role="navigation">
		<%
			request.setAttribute("LEFT", "websitelist");
		%> <%@include
			file="left-factory.jsp"%> </nav>

		<div id="page-wrapper" class="gray-bg">
			<div class="row border-bottom">
				<jsp:include page="head-factory.jsp" flush="true" />
			</div>
			<div class="row wrapper border-bottom white-bg page-heading">
				<div class="col-lg-10">
					<h2>编辑种子</h2>
				</div>
			</div>
			<div class="wrapper wrapper-content">
				<div class="ibox-content">

					<span style="font-size: 17px;" id="configid"
						data-id="${config.id }" data-seedid="${config.seed_id }"></span>
					<div class="table-responsive" style="margin-top: 5%;">
						<div class="search-result">
							<span style="font-size: 17px;">&nbsp;
								<button class="btn btn-white pull-left"
									onclick="window.history.go(-1)" type="button">返回</button>
							</span>
							<div style="display: inline; float: right; margin-right: 12%;">
								线程数:<select class="form-control"
									style="display: inline; width: auto;" id="seedthreadconfig"
									name="seedthreadconfig">
									<option value="1"
										<c:if test="${config.seed_thread_config == 1 }">selected</c:if>>1条</option>
									<option value="5"
										<c:if test="${config.seed_thread_config == 5 }">selected</c:if>>5条</option>
									<option value="10"
										<c:if test="${config.seed_thread_config == 10 }">selected</c:if>>10条</option>
								</select> &nbsp;&nbsp;&nbsp;&nbsp;抓取间隔:<select class="form-control"
									style="display: inline; width: auto;" id="seedintervalconfig"
									name="seedintervalconfig">
									<option value="60000"
										<c:if test="${config.seed_interval_config eq 60000 }">selected</c:if>>1分钟</option>
									<option value="600000"
										<c:if test="${config.seed_interval_config eq 600000 }">selected</c:if>>10分钟</option>
									<option value="1800000"
										<c:if test="${config.seed_interval_config eq 180000 }">selected</c:if>>30分钟</option>
									<option value="3600000"
										<c:if test="${config.seed_interval_config eq 360000 }">selected</c:if>>60分钟</option>
								</select> &nbsp;&nbsp;&nbsp;&nbsp;访问URL间隔:<select class="form-control"
									style="display: inline; width: auto;" id="seedsleepconfig"
									name="seedsleepconfig">
									<option value="1000"
										<c:if test="${config.seed_sleep_config == 1000 }">selected</c:if>>1秒</option>
									<option value="2000"
										<c:if test="${config.seed_sleep_config == 2000 }">selected</c:if>>2秒</option>
									<option value="3000"
										<c:if test="${config.seed_sleep_config == 3000 }">selected</c:if>>3秒</option>
									<option value="4000"
										<c:if test="${config.seed_sleep_config == 4000 }">selected</c:if>>4秒</option>
									<option value="5000"
										<c:if test="${config.seed_sleep_config == 5000 }">selected</c:if>>5秒</option>
								</select>
							</div>
						</div>
						<div class="hr-line-dashed"></div>
						<div class="panel-body">
							<form
								action="${pageContext.request.contextPath}/spiderconfig/test"
								method="post" target="_blank">

								<fieldset class="form-horizontal">
									<div class="form-group">
										<label class="col-sm-2 control-label">选择配置方式:</label>
										<c:if test="${config.seed_spider_type == 1 }">
											<div class="col-sm-10">
												<div class="btn-group">
													<button id="smartbutton" class="btn btn-white active"
														type="button" onclick="configTypeChange(1)">智能配置</button>
													<button id="manualbutton" class="btn btn-white"
														type="button" onclick="configTypeChange(2)">手动配置</button>
												</div>
											</div>
										</c:if>
										<c:if test="${config.seed_spider_type == 2 }">
											<div class="col-sm-10">
												<div class="btn-group">
													<button id="smartbutton" class="btn btn-white"
														type="button" onclick="configTypeChange(1)">智能配置</button>
													<button id="manualbutton" class="btn btn-white active"
														type="button" onclick="configTypeChange(2)">手动配置</button>
												</div>
											</div>
										</c:if>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label"><span
											style="color: red; font-size: 16px; line-height: 0px;">*</span>配置存储板块:</label>




										<%-- <select id="se1" name="seedid" data-id="${config.other_seed_id }" class="form-control" style="display: inline;width: auto;margin-left:15px;">
							    		</select>
							    <!-- <input type="button" value="test" onclick="var v = $('#se1').val();alert(v);" /> -->
										</div>
										<div class="form-group"><label class="col-sm-2 control-label"><span style="color:red;font-size:16px;line-height:0px;">*</span>配置文章分类:</label>
									<select id="se2" name="seedid" class="form-control" data-id="${config.seed_article_type}" style="display: inline;width: auto;margin-left:15px;">
							    </select> --%>





										<select id="se1" name="seedid"
											data-id="${config.other_seed_id }" class="form-control"
											style="display: inline; width: auto; margin-left: 15px;">
										</select>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label"><span
											style="color: red; font-size: 16px; line-height: 0px;">*</span>配置文章分类:</label>
										<select id="se2" name="seedid1" class="form-control"
											data-id="${config.seed_article_type}"
											style="display: inline; width: auto; margin-left: 15px;">
										</select>
										<!-- <input type="button" value="test" onclick="var v = $('#se1').val();alert(v);" /> -->
									</div>
									<div id="dailiflag" value="${config.daili_flag }"
										class="form-group">
										<label class="col-sm-2 control-label"><span
											style="color: red; font-size: 16px; line-height: 0px;"></span>是否使用代理:</label>
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<div class="radio-inline">
											<input type="radio" name="killOrder1" value="1" /> <label
												for="killOrder1">是</label>
										</div>
										<div class="radio-inline">
											<input type="radio" name="killOrder1" value="0" checked /> <label
												for="killOrder1">否</label>
										</div>

									</div>
									<div id="seleniumflag" value="${config.selenium_flag }"
										class="form-group">
										<label class="col-sm-2 control-label">是否使用Selenium:</label>
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<div id="radio-inline" class="radio-inline">
											<input type="radio" name="killOrder2" value="1" /> <label
												for="killOrder2">是</label>
										</div>
										<div class="radio-inline">
											<input type="radio" name="killOrder2" value="0" checked /> <label
												for="killOrder2">否</label>
										</div>


									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label"><span
											style="color: red; font-size: 16px; line-height: 0px;">*</span>种子地址名称:</label>
										<div class="col-sm-10">
											<input type="text" value="${config.seed_name }" id="seedname"
												class="form-control" style="width: 88%;"
												placeholder="请输入您需要采集的地址名称，例如：北京晨报-国际要闻">
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label"><span
											style="color: red; font-size: 16px; line-height: 0px;">*</span>种子地址列表:</label>
										<div class="col-sm-10">
											<input type="text" value="${config.seed_list_url }"
												id="seedurllist" name="seedurllist" class="form-control"
												style="width: 88%;" placeholder="请输入URL的列表采集地址">
										</div>
									</div>
									<c:if test="${config.seed_spider_type == 1 }">
										<input id="spiderId" name="spiderId" value="1" type="hidden">
									</c:if>
									<c:if test="${config.seed_spider_type == 2 }">
										<input id="spiderId" name="spiderId" value="2" type="hidden">
									</c:if>
									<div class="form-group">
										<label class="col-sm-2 control-label"><span
											style="color: red; font-size: 16px; line-height: 0px;">*</span>配置正文类型:</label>
										<select class="form-control"
											style="display: inline; width: auto; margin-left: 15px;"
											id="seedtype" name="seedtype">
											<option value="0"
												<c:if test="${config.seed_text_config_type == 0 }">selected</c:if>>选择正文类型</option>
											<option value="1"
												<c:if test="${config.seed_text_config_type == 1 }">selected</c:if>>HTML</option>
											<option value="2"
												<c:if test="${config.seed_text_config_type == 2 }">selected</c:if>>JSON</option>
											<option value="3"
												<c:if test="${config.seed_text_config_type == 3 }">selected</c:if>>HTML>CDATA</option>
											<option value="4"
												<c:if test="${config.seed_text_config_type == 4 }">selected</c:if>>HTML>JavaScript</option>
										</select>
										<!-- <span style="color:red;font-size:14px;line-height:0px;">*</span>请重新确认配置正文类型 -->
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label"><span
											style="color: red; font-size: 16px; line-height: 0px;">*</span>配置列表规则:</label>
										<div class="col-sm-10">
											<input type="text" 
												id="seedurlconfig" name="seedurlconfig" class="form-control"
												style="width: 88%;" placeholder="请输入列表页Xpath">
										</div>
									</div>




									<div class="form-group">
										<label class="col-sm-2 control-label">配置路径规则:</label>
										<div class="col-sm-10">
											<input type="text" value="${config.seed_linkurl_config }"
												id="seedlinkurlconfig" name="seedlinkurlconfig"
												class="form-control" style="width: 88%;"
												placeholder="需要拼接url时填入此项">
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label"><span
											style="color: red; font-size: 16px; line-height: 0px;">*</span>配置存储规则:</label>

										<c:set var="seed_storage_type"
											value="${config.seed_storage_type }" />
										<c:set value="${ fn:split(seed_storage_type, ',') }"
											var="storageTypes" />
										<c:set var="MySQL" value="0" />
										<c:set var="MongoDB" value="0" />
										<c:set var="ES" value="0" />
										<c:forEach items="${ storageTypes }" var="storageType">
											<c:if test="${storageType eq 1 }">
												<c:set var="MySQL" value="1" />
											</c:if>
											<c:if test="${storageType eq 2 }">
												<c:set var="MongoDB" value="1" />
											</c:if>
											<c:if test="${storageType eq 3 }">
												<c:set var="ES" value="1" />
											</c:if>
										</c:forEach>
										<div class="checkbox">
											<input id="checkbox1" name="seedtextStorageJson"
												<c:if test="${MySQL == 1 }">checked="checked"</c:if>
												type="checkbox" value="1" class="seedtextStorageJson">
											<label for="checkbox1">MySQL</label>
										</div>
										<div class="checkbox">
											<input id="checkbox2" name="seedtextStorageJson"
												<c:if test="${MongoDB == 1 }">checked="checked"</c:if>
												type="checkbox" value="2" class="seedtextStorageJson">
											<label for="checkbox2">MongoDB</label>
										</div>
										<div class="checkbox">
											<input id="checkbox3" name="seedtextStorageJson"
												<c:if test="${ES == 1 }">checked="checked"</c:if>
												type="checkbox" value="3" class="seedtextStorageJson">
											<label for="checkbox3">ES</label>
										</div>
										<!-- <select class="form-control" style="display: inline;width: auto;margin-left: 1%;" id="seedtextStorageJson">
													<option value="1" selected>mysql</option>
													<option value="2">mongodb</option>
													<option value="3">es</option>
												</select> -->
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">配置作者规则:</label>
										<div class="col-sm-10">
											<input type="text" id="seedauthorconfig"
												name="seedauthorconfig"
												value="${config.seed_author_config }" class="form-control"
												style="width: 88%;" placeholder="需要作者填入此项">
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">配置作者主页规则:</label>
										<div class="col-sm-10">
											<input type="text" id="seedauthorurlconfig"
												name="seedauthorurlconfig"
												value="${config.seed_author_url_config }"
												class="form-control" style="width: 88%;"
												placeholder="需要拼接作者主页时填入此项">
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">配置作者头像规则:</label>
										<div class="col-sm-10">
											<input type="text" id="seedauthoravatarconfig"
												name="seedauthoravatarconfig"
												value="${config.seed_author_avatar_config }"
												class="form-control" style="width: 88%;"
												placeholder="需要拼接作者头像时填入此项">
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">配置分页json规则:</label>
										<div class="col-sm-10">
											<input type="text" id="seedpageruleconfig"
												name="seedpageruleconfig"
												class="form-control" style="width: 88%;"
												placeholder='需要分页抓取时填入此项,demo:{"replace_demo":"_*","replace_rule":"*-1","first":"","pagenum":"200"}'>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">配置列表请求规则:</label>
										<div class="col-sm-10">
											<input type="text" id="seeddetailrequestparam"
												name="seeddetailrequestparam"
												class="form-control" style="width: 88%;"
												placeholder='需要拼接详情页请求时需要参数填入此项 如Referer Query String Parameters 等'>
										</div>
									</div>
									<c:if test="${config.seed_spider_type == 1 }">
										<div class="form-group configtype" style="display: none;">
											<label class="col-sm-2 control-label"><span
												style="color: red; font-size: 16px; line-height: 0px;">*</span>配置标题规则:</label>
											<div class="col-sm-10">
												<input type="text" value="${config.seed_title_config }"
													id="seedtitleconfig" name="seedtitleconfig"
													class="form-control" style="width: 88%;"
													placeholder="请输入标题解析代码">
											</div>
										</div>
										<div class="form-group configtype" style="display: none;">
											<label class="col-sm-2 control-label">配置来源规则:</label>
											<div class="col-sm-10">
												<input type="text" value="${config.seed_origin_config }"
													id="seedoriginconfig" name="seedoriginconfig"
													class="form-control" style="width: 88%;"
													placeholder="请输入来源解析代码">
											</div>
										</div>
										<div class="form-group configtype" style="display: none;">
											<label class="col-sm-2 control-label">配置来源URL规则:</label>
											<div class="col-sm-10">
												<input type="text" value="${config.seed_origin_url_config }"
													id="seedoriginurlconfig" name="seedoriginurlconfig"
													class="form-control" style="width: 88%;"
													placeholder="请输入来源URL解析代码">
											</div>
										</div>
										<div class="form-group configtype" style="display: none;">
											<label class="col-sm-2 control-label"><span
												style="color: red; font-size: 16px; line-height: 0px;">*</span>配置日期规则:</label>
											<div class="col-sm-10">
												<input type="text" value="${config.seed_date_config }"
													id="seeddateconfig" name="seeddateconfig"
													class="form-control" style="width: 88%;"
													placeholder="请输入日期解析代码">
											</div>
										</div>
										<div class="form-group configtype" style="display: none;">
											<label class="col-sm-2 control-label"><span
												style="color: red; font-size: 16px; line-height: 0px;">*</span>正文解析规则:</label>
											<div class="col-sm-10">
												<input type="text" id="seedtextconfig" name="seedtextconfig"
													value="${config.seed_text_config }" class="form-control"
													style="width: 88%;" placeholder="请输入正文解析规则">
											</div>
										</div>
									</c:if>
									<c:if test="${config.seed_spider_type == 2 }">
										<div class="form-group configtype" style="display: block;">
											<label class="col-sm-2 control-label"><span
												style="color: red; font-size: 16px; line-height: 0px;">*</span>配置标题规则:</label>
											<div class="col-sm-10">
												<input type="text" value="${config.seed_title_config }"
													id="seedtitleconfig" name="seedtitleconfig"
													class="form-control" style="width: 88%;"
													placeholder="请输入标题解析代码">
											</div>
										</div>
										<div class="form-group configtype" style="display: block;">
											<label class="col-sm-2 control-label">配置来源规则:</label>
											<div class="col-sm-10">
												<input type="text" value="${config.seed_origin_config }"
													id="seedoriginconfig" name="seedoriginconfig"
													class="form-control" style="width: 88%;"
													placeholder="请输入来源解析代码">
											</div>
										</div>
										<div class="form-group configtype" style="display: block;">
											<label class="col-sm-2 control-label">配置来源URL规则:</label>
											<div class="col-sm-10">
												<input type="text" value="${config.seed_origin_url_config }"
													id="seedoriginurlconfig" name="seedoriginurlconfig"
													class="form-control" style="width: 88%;"
													placeholder="请输入来源URL解析代码">
											</div>
										</div>
										<div class="form-group configtype" style="display: block;">
											<label class="col-sm-2 control-label"><span
												style="color: red; font-size: 16px; line-height: 0px;">*</span>配置日期规则:</label>
											<div class="col-sm-10">
												<input type="text" value="${config.seed_date_config }"
													id="seeddateconfig" name="seeddateconfig"
													class="form-control" style="width: 88%;"
													placeholder="请输入日期解析代码">
											</div>
										</div>
										<div class="form-group configtype" style="display: block;">
											<label class="col-sm-2 control-label"><span
												style="color: red; font-size: 16px; line-height: 0px;">*</span>正文解析规则:</label>
											<div class="col-sm-10">
												<input type="text" id="seedtextconfig" name="seedtextconfig"
													value="${config.seed_text_config }" class="form-control"
													style="width: 88%;" placeholder="请输入正文解析规则">
											</div>
										</div>
									</c:if>
								</fieldset>
								<button class="btn btn-primary"
									style="margin-left: 20%; margin-top: 2%;" type="submit">测试种子</button>
								<c:if test="${config.seed_spider_type == 1 }">
									<button id="savebutton" class="btn btn-primary"
										style="margin-left: 38%; margin-top: 2%;"
										onclick="updatesmartSeed()" type="button">保存</button>
								</c:if>
								<c:if test="${config.seed_spider_type == 2 }">
									<button id="savebutton" class="btn btn-primary"
										style="margin-left: 38%; margin-top: 2%;"
										onclick="updateSeed()" type="button">保存</button>
								</c:if>
							</form>
						</div>
					</div>
					</form>
				</div>
			</div>
			<jsp:include page="footer.jsp" flush="true" />
		</div>
	</div>



	<!-- Mainly scripts -->
	<script src="${pageContext.request.contextPath }/js/jquery-2.1.1.js"></script>
	<script src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/js/jquery.metisMenu.js"></script>
	<script
		src="${pageContext.request.contextPath }/js/jquery.slimscroll.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/js/jquery.jeditable.js"></script>
	<script src="${pageContext.request.contextPath }/js/datatables.min.js"></script>

	<!-- Peity -->
	<script
		src="${pageContext.request.contextPath }/js/jquery.peity.min.js"></script>

	<!-- Custom and plugin javascript -->
	<script src="${pageContext.request.contextPath }/js/inspinia.js"></script>
	<script src="${pageContext.request.contextPath }/js/pace.min.js"></script>

	<!-- Peity -->
	<script src="${pageContext.request.contextPath }/js/peity-demo.js"></script>

	<!-- toastr -->
	<script src="js/plugins/toastr/toastr.min.js"></script>

	<!-- Sweet alert -->
	<script
		src="${pageContext.request.contextPath }/js/plugins/sweetalert/sweetalert.min.js"></script>

	<script
		src="${pageContext.request.contextPath }/js/jquery.searchableSelect.js"></script>

	<!-- Page-Level Scripts -->
	<script>
   
//     function gettype(e){
//     	$.ajax({
// 	        type:"POST",
// 	        url:"${pageContext.request.contextPath}/news/getType?flag="+e,
// 	        data:{},
// 			dataType:'json',
// 			success:function(data){
// 				var seed_type_id = $('#se2').attr("data-id");
// 		  		var htmlStr = "";
// 		  		var length = data.length;
// 		  			htmlStr +="<option value=''>请选择</option>";
// 		  			for(j=0;j<length;j++){
// 		  				if(!(!seed_type_id)){
// 		  				if(seed_type_id == data[j].seed_id){
// 		  					htmlStr += "<option value='"+ data[j].seed_id +"'  selected = 'selected' >"
// 				  			+data[j].seed_name+"</option>";
// 		  				}else{
// 		  					htmlStr += "<option value='"+ data[j].seed_id +"'>"
// 				  			+data[j].seed_name+"</option>";
// 		  				}
// 	  				}else{
// 	  					htmlStr += "<option value='"+ data[j].seed_id +"'>"
// 			  			+data[j].seed_name+"</option>";
// 	  				}
// 		  			}
// 				$('#se2').html(htmlStr);
// 		    	$('#se2').searchableSelect();
// 			},
// 		})
//     }
    
    $(function() {
    	
    	$.ajax({
	        type:"POST",
	        url:"${pageContext.request.contextPath}/news/getSeedIds",
	        data:{},
			dataType:'json',
			success:function(data){
				var otherseedid = $('#se1').attr("data-id");
		  		var htmlStr = "";
		  		var length = data.length;
		  			htmlStr +="<option value=''>请选择</option>";
		  			for(j=0;j<length;j++){
		  				if(!(!otherseedid)){
			  				if(otherseedid == data[j].seed_id){
			  					htmlStr += "<option value='"+ data[j].seed_id +"' onclick='gettype("+data[j].seed_id+")'  selected = 'selected' >"
					  			+data[j].seed_name+"</option>";
			  				}else{
			  					htmlStr += "<option onclick='gettype("+data[j].seed_id+")' value='"+ data[j].seed_id +"'>"
					  			+data[j].seed_name+"</option>";
			  				}
		  				}else{
		  					htmlStr += "<option onclick='gettype("+data[j].seed_id+")' value='"+ data[j].seed_id +"'>"
				  			+data[j].seed_name+"</option>";
		  				}
		  			}
				$('#se1').html(htmlStr);
		    
		    	
			},
		});
    	
    	
    	
    }
    
    
    );

    

   
    
//     $(function() {
//     	var otherseedid = $('#se1').attr("data-id");
//     	if(otherseedid !=0){
//     		$.ajax({
//     	        type:"POST",
//     	        url:"${pageContext.request.contextPath}/news/getType?flag="+otherseedid,
//     	        data:{},
//     			dataType:'json',
//     			success:function(data){
//     				var seed_type_id = $('#se2').attr("data-id");
//     		  		var htmlStr = "";
//     		  		var length = data.length;
//     		  			htmlStr +="<option value=''>请选择</option>";
//     		  			for(j=0;j<length;j++){
//     		  				if(!(!seed_type_id)){
//     		  				if(seed_type_id == data[j].seed_id){
//     		  					htmlStr += "<option value='"+ data[j].seed_id +"'  selected = 'selected' >"
//     				  			+data[j].seed_name+"</option>";
//     		  				}else{
//     		  					htmlStr += "<option value='"+ data[j].seed_id +"'>"
//     				  			+data[j].seed_name+"</option>";
//     		  				}
//     	  				}else{
//     	  					htmlStr += "<option value='"+ data[j].seed_id +"'>"
//     			  			+data[j].seed_name+"</option>";
//     	  				}
//     		  			}
//     				$('#se2').html(htmlStr);
//     		    	$('#se2').searchableSelect();
//     			},
//     		});
//     	}else{
//     		$.ajax({
//     	        type:"POST",
//     	        url:"${pageContext.request.contextPath}/news/getType",
//     	        data:{},
//     			dataType:'json',
//     			success:function(data){
//     				var seed_type_id = $('#se2').attr("data-id");
//     		  		var htmlStr = "";
//     		  		var length = data.length;
//     		  			htmlStr +="<option value=''>请选择</option>";
//     		  			for(j=0;j<length;j++){
//     		  				if(!(!seed_type_id)){
//     		  				if(seed_type_id == data[j].seed_id){
//     		  					htmlStr += "<option value='"+ data[j].seed_id +"'  selected = 'selected' >"
//     				  			+data[j].seed_name+"</option>";
//     		  				}else{
//     		  					htmlStr += "<option value='"+ data[j].seed_id +"'>"
//     				  			+data[j].seed_name+"</option>";
//     		  				}
//     	  				}else{
//     	  					htmlStr += "<option value='"+ data[j].seed_id +"'>"
//     			  			+data[j].seed_name+"</option>";
//     	  				}
//     		  			}
//     				$('#se2').html(htmlStr);
//     		    	$('#se2').searchableSelect();
//     			},
//     		});
//     	}
    	
    	
    	
    	
//     	/* $("#se1").change(function () {
//     		//这里写你想要的验证的代码；
//     		alert("3232");
//     	}); */
    	
//       });
    
    /* function gettypeconfig(){
        console.log("你好")
    } */
  
    function configTypeChange(num){
		if(num == 1){
			$("#smartbutton").attr("class","btn btn-white active")
			$("#manualbutton").attr("class","btn btn-white")
			$(".configtype").attr("style","display: none;")
			$("#savebutton").attr("onclick","updatesmartSeed()")
			$("#spiderId").val(1);
		}else if(num == 2){
			$("#smartbutton").attr("class","btn btn-white")
			$("#manualbutton").attr("class","btn btn-white active")
			$(".configtype").attr("style","display:block;")
			$("#savebutton").attr("onclick","updateSeed()")
			$("#spiderId").val(2);
		}
	}
function updatesmartSeed(){
	console.log($("input[name='killOrder1']:checked").attr("value"))
	console.log($("input[name='killOrder2']:checked").attr("value"))
    	
    	if($("#seedname").val()==null||$("#seedname").val()=="")
    	{
    		toastr.error('请填写需要采集的地址名')
    		return;
    	}else if($("#seedurllist").val()==null||$("#seedurllist").val()=="")
    	{
    		toastr.error('请填写需要采集的地址列表')
    		return;
    	}else if($("#seedtype").val()==null||$("#seedtype").val()==0)
    	{
    		toastr.error('请填写需要配置的正文类型')
    		return;
    	}else if($("#seedurlconfig").val()==null||$("#seedurlconfig").val()=="")
    	{
    		toastr.error('请填写需要配置的列表规则')
    		return;
    	}else if(!$("#checkbox1").prop('checked')&&!$("#checkbox2").prop('checked')&&!$("#checkbox3").prop('checked'))
    	{
    		toastr.error('请选择需要配置的存储规则')
    		return;
    	}else if($("#se1").val()==null||$("#se1").val()=="")
    	{
    		toastr.error('请选择存储板块')
    		return;
    	}else if($("#se2").val()==null||$("#se2").val()=="")
    	{
    		toastr.error('请选择文章的分类')
    		return;
    	}
	var sRegex = '(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]';
	var re = new RegExp(sRegex);
	if (!re.test($("#seedurllist").val())) {
    	toastr.error('url填写不正确')
    	return;
    }
// 	if (re.test($("#seedurllist").val())) {
//         return true;
//     }else{
//     	toastr.error('url填写不正确')
//     	return;
//     }

    	/* text = $("input:checkbox[name='seedtextStorageJson']:checked").map(function(index,elem) {
            return $(elem).val();
        }).get().join(','); */
        swal({
            title: "确定修改?",
//          text: "Your will not be able to recover this imaginary file!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: false,
            closeOnCancel: true },
        function (isConfirm) {
            if (isConfirm) {
            	
//             	if(!$('#se1').val()){
//               	   var data = {
//               			 id : $("#configid").attr("data-id"),
//              			seedId : $("#configid").attr("data-seedid"),
//              			websiteId : $("#websiteId").attr("data-id"),
//              			seedthreadconfig : $("#seedthreadconfig").val(),
//              			seedintervalconfig : $("#seedintervalconfig").val(),
//              			seedsleepconfig : $("#seedsleepconfig").val(),
//              			seedname : $("#seedname").val(),
//              			seedurllist : $("#seedurllist").val(),
//              			seedstoragejson : $("input:checkbox[name='seedtextStorageJson']:checked").map(function(index,elem) {
//              	            return $(elem).val();
//              	        }).get().join(','),
//              			seedtextconfigtype : $("#seedtype").val(),
//              			seedtype : $("#seedtype").val(),
//              			seedurlconfig : $("#seedurlconfig").val(),
//              			seedlinkurlconfig : $("#seedlinkurlconfig").val(),
//              			dailiflag : $("input[name='killOrder1']:checked").val(),
//             			seleniumflag : $("input[name='killOrder2']:checked").val(),
//              			seedarticletype : $("#se2").val(),
//              			seedspidertype : 1
//               		}
//                  }else{
              	   data = {
              			 id : $("#configid").attr("data-id"),
             			seedId : $("#configid").attr("data-seedid"),
             			websiteId : $("#websiteId").attr("data-id"),
             			seedthreadconfig : $("#seedthreadconfig").val(),
             			seedintervalconfig : $("#seedintervalconfig").val(),
             			seedsleepconfig : $("#seedsleepconfig").val(),
             			seedname : $("#seedname").val(),
             			seedurllist : $("#seedurllist").val(),
             			seedstoragejson : $("input:checkbox[name='seedtextStorageJson']:checked").map(function(index,elem) {
             	            return $(elem).val();
             	        }).get().join(','),
             			seedtextconfigtype : $("#seedtype").val(),
             			seedtype : $("#seedtype").val(),
             			seedurlconfig : $("#seedurlconfig").val(),
             			seedlinkurlconfig : $("#seedlinkurlconfig").val(),
             			dailiflag : $("input[name='killOrder1']:checked").val(),
            			seleniumflag : $("input[name='killOrder2']:checked").val(),
             			seedarticletype : $("#se2").val(),
             			seedspidertype : 1,
             			otherseedid:$('#se1').val(),
             			otherwebsiteId:15
              		}
//                  }
console.log(data)
            	$.ajax({
            		url : "${pageContext.request.contextPath}/updateSeedConfig",
            		type : "post",
            		data : data,
            		success : function(res) {
            			console.log(res)
            			if (res.status == 200) {
            				//toastr.success(res.msg);
            				swal("修改成功", "该种子已被修改", "success");
            				setTimeout(() => {
            					window.location.href = "${pageContext.request.contextPath}/getseeddetail?seedid="+${config.seed_id };
        					}, 3000);
            			} else {
            				swal("修改失败", "该种子未被修改", "error");
            			}
            		},
            		error : function(e) {
            			//toastr.error(res.msg);
            			swal("修改失败", "该种子未被修改", "error");
            			window.clearInterval(timer);
            		}
            	});
                
            } 
        });
        
    	
    }
	function updateSeed(){
		var sRegex = '(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]';
    	var re = new RegExp(sRegex);
    	if (!re.test($("#seedurllist").val())) {
        	toastr.error('url填写不正确')
        	return;
        }
	    	if($("#seedname").val()==null||$("#seedname").val()=="")
	    	{
	    		toastr.error('请填写需要采集的地址名')
	    		return;
	    	}else if($("#seedurllist").val()==null||$("#seedurllist").val()=="")
	    	{
	    		toastr.error('请填写需要采集的地址列表')
	    		return;
	    	}else if($("#seedtype").val()==null||$("#seedtype").val()==0)
	    	{
	    		toastr.error('请填写需要配置的正文类型')
	    		return;
	    	}else if($("#seedurlconfig").val()==null||$("#seedurlconfig").val()=="")
	    	{
	    		toastr.error('请填写需要配置的列表规则')
	    		return;
	    	}else if($("#seedtitleconfig").val()==null||$("#seedtitleconfig").val()=="")
	    	{
	    		toastr.error('请填写需要配置的标题规则')
	    		return;
	    	}else if($("#seeddateconfig").val()==null||$("#seeddateconfig").val()=="")
	    	{
	    		toastr.error('请填写需要配置的日期规则')
	    		return;
	    	}else if(!$("#checkbox1").prop('checked')&&!$("#checkbox2").prop('checked')&&!$("#checkbox3").prop('checked'))
	    	{
	    		toastr.error('请选择需要配置的存储规则')
	    		return;
	    	}else if($("#seedtextconfig").val()==null||$("#seedtextconfig").val()=="")
	    	{
	    		toastr.error('请填写需要配置的正文规则')
	    		return;
	    	}else if($("#se1").val()==null||$("#se1").val()=="")
	    	{
	    		toastr.error('请选择存储板块')
	    		return;
	    	}else if($("#se2").val()==null||$("#se2").val()=="")
	    	{
	    		toastr.error('请选择文章的分类')
	    		return;
	    	}
		
	
	    	/* text = $("input:checkbox[name='seedtextStorageJson']:checked").map(function(index,elem) {
	            return $(elem).val();
	        }).get().join(','); */
	        
	        swal({
                title: "确定修改?",
//              text: "Your will not be able to recover this imaginary file!",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: false,
                closeOnCancel: true },
            function (isConfirm) {
                if (isConfirm) {
                 	   data = {
                 			  id : $("#configid").attr("data-id"),
          	    			seedId : $("#configid").attr("data-seedid"),
          	    			seedname : $("#seedname").val(),
          	    			seedtype : $("#seedtype").val(),
          	    			seeddateconfig : $("#seeddateconfig").val(),
          	    			seedintervalconfig : $("#seedintervalconfig").val(),
          	    			seedsleepconfig : $("#seedsleepconfig").val(),
          	    			seedurllist : $("#seedurllist").val(),
          	    			seedstoragejson : $("input:checkbox[name='seedtextStorageJson']:checked").map(function(index,elem) {
          	    	            return $(elem).val();
          	    	        }).get().join(','),
          	    			seedtextconfig : $("#seedtextconfig").val(),
          	    			seedtextconfigtype : $("#seedtype").val(),
          	    			seedthreadconfig : $("#seedthreadconfig").val(),
          	    			seedtitleconfig : $("#seedtitleconfig").val(),
          	    			seedurlconfig : $("#seedurlconfig").val(),
          	    			seeddateconfig : $("#seeddateconfig").val(),
          	    			seedlinkurlconfig : $("#seedlinkurlconfig").val(),
          	    			seedoriginconfig : $("#seedoriginconfig").val(),
          	    			seedoriginurlconfig : $("#seedoriginurlconfig").val(),
          	    			dailiflag : $("input[name='killOrder1']:checked").val(),
                			seleniumflag : $("input[name='killOrder2']:checked").val(),
          	    			seedarticletype : $("#se2").val(),
          	    			seedspidertype : 2,
          	    			otherseedid:$('#se1').val(),
          	    			otherwebsiteId:15
                 		}
                    $.ajax({
        	    		url : "${pageContext.request.contextPath}/updateSeedConfig",
        	    		type : "post",
        	    		data : data,
        	    		success : function(res) {
        	    			console.log(res)
        	    			if (res.status == 200) {
        	    				//toastr.success(res.msg);
        	    				swal("修改成功", "该种子已修改", "success");
        	    				setTimeout(() => {
        	    					window.location.href = "${pageContext.request.contextPath}/getseeddetail?seedid="+${config.seed_id };
        						}, 3000);
        	    			} else {
        	    				//toastr.error(res.msg);
        	    				swal("修改失败", "该种子未修改", "error");
        	    			}
        	    		},
        	    		error : function(e) {
        	    			//toastr.error(res.msg);
        	    			swal("修改失败", "该种子未修改", "error");
        	    			window.clearInterval(timer);
        	    			
        	    		}
        	    	});
                } 
            });
	        
	    }
	$(function(){
		$("#seedpageruleconfig").val( '${config.seed_page_rule_config }')
		$("#seedurlconfig").val( '${config.seed_url_config }')
		$("#seeddetailrequestparam").val( '${config.seed_detail_request_param }')
		
    	console.log("你好")
		var seleniumflag=$('#seleniumflag').attr("value")
		var dailiflag=$('#dailiflag').attr("value")
		console.log(seleniumflag)
		console.log(dailiflag)
    	$(":radio[name='killOrder1'][value='" + dailiflag + "']").prop("checked", "checked");
    	$(":radio[name='killOrder2'][value='" + seleniumflag + "']").prop("checked", "checked");
    	
    })
	
function check(){
    	
    	if($("#seedname").val()==null||$("#seedname").val()=="")
    	{
    		toastr.error('请填写需要采集的地址名')
    		return;
    	}else if($("#seedurllist").val()==null||$("#seedurllist").val()=="")
    	{
    		toastr.error('请填写需要采集的地址列表')
    		return;
    	}else if($("#seedtype").val()==null||$("#seedtype").val()==0)
    	{
    		toastr.error('请填写需要配置的正文类型')
    		return;
    	}else if($("#seedurlconfig").val()==null||$("#seedurlconfig").val()=="")
    	{
    		toastr.error('请填写需要配置的列表规则')
    		return;
    	}else if($("#seedtitleconfig").val()==null||$("#seedtitleconfig").val()=="")
    	{
    		toastr.error('请填写需要配置的标题规则')
    		return;
    	}else if($("#seeddateconfig").val()==null||$("#seeddateconfig").val()=="")
    	{
    		toastr.error('请填写需要配置的日期规则')
    		return;
    	}else if(!$("#checkbox1").prop('checked')&&!$("#checkbox2").prop('checked')&&!$("#checkbox3").prop('checked'))
    	{
    		toastr.error('请选择需要配置的存储规则')
    		return;
    	}else if($("#seedtextconfig").val()==null||$("#seedtextconfig").val()=="")
    	{
    		toastr.error('请填写需要配置的正文规则')
    		return;
    	}else if($("#se1").val()==null||$("#se1").val()=="")
    	{
    		toastr.error('请选择存储板块')
    		return;
    	}else if($("#se2").val()==null||$("#se2").val()=="")
    	{
    		toastr.error('请选择文章的分类')
    		return;
    	}
    	window.open("${pageContext.request.contextPath}/spiderconfig/test?seedtype="+$("#seedtype").val()+"&seeddateconfig="
    			+$("#seeddateconfig").val()+"&seedintervalconfig="+$("#seedintervalconfig").val()
    			+"&seedsleepconfig="+$("#seedsleepconfig").val()
    			+"&seedurllist="+$("#seedurllist").val()+"&seedtextconfig="+$("#seedtextconfig").val()+
    			"&seedthreadconfig="+$("#seedthreadconfig").val()+"&seedtitleconfig="+$("#seedtitleconfig").val()
    			+"&seedurlconfig="+$("#seedurlconfig").val()+"&seedlinkurlconfig="+$("#seedlinkurlconfig").val()
    			+"&seedoriginconfig="+$("#seedoriginconfig").val())
    }
	$("#se1").on('change',function(){
		$.ajax({
			url:"${pageContext.request.contextPath}/news/getType",
			type:"post",
			data:{
				flag:$("#se1").val()
			},
			success:function(data){
				data = JSON.parse(data);
				console.log(data)
				var htmlStr = "";
		  		var length = data.length;
		  			htmlStr +="<option value=''>请选择</option>";
		  			var seed_type_id = $('#se2').attr("data-id");
		  			for(j=0;j<length;j++){
		  				if(!(!seed_type_id)){
		  				if(seed_type_id == data[j].seed_id){
		  					htmlStr += "<option value='"+ data[j].seed_id +"'  selected = 'selected' >"
				  			+data[j].seed_name+"</option>";
		  				}else{
		  					htmlStr += "<option value='"+ data[j].seed_id +"'>"
				  			+data[j].seed_name+"</option>";
		  				}
	  				}else{
	  					htmlStr += "<option value='"+ data[j].seed_id +"'>"
			  			+data[j].seed_name+"</option>";
	  				}
		  			}
		  		$("#se2").html("");
				$('#se2').html(htmlStr);
			},
			error:function(e){
				
			}
		})
	})
    
    
    
//跑马灯方法 
// function init(){
// 	    //获取标题
// 	    var title=document.title;
// 	    //分割字符串--->字符数组
// 	    var arr=title.split("");
// 	    //删除第一个元素并返回该元素
// 	    var e=arr.shift();
// 	    //把一个对象添加到数组末尾
// 	    arr.push(e);
// 	    //把数组转换成字符串
// 	    var marquee=arr.join("");
// 	    //返回给浏览器
// 	    document.title=marquee;
// 	    //定时一直执行
// 	    window.setTimeout("init()",1000);
// 	}
// 	window.onload=init;
	
	
		
		
    </script>

</body>

</html>
